﻿package  {
	
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.display.MovieClip;
	import flash.utils.*;
	import flash.net.*;
	import flash.events.*;
	import flash.display.Bitmap;
	import com.greensock.easing.*;
	import com.greensock.TweenMax;
	
	public class picBig extends MovieClip {
		private var _url:String;
		private var loader:Loader
		public var bitmap:Bitmap;
		private var thisW:Number = 880;
		public var targetIBiao:int;
		
		public function picBig() {
			// constructor code
		}
		public function setUrl(str:String) {
			_url = str;
			loader = new Loader();
			loader.load(new URLRequest(_url));
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleteHandler);
		}
		private function loadCompleteHandler(e:Event):void
		{
			var loaderT:Loader = e.target.loader as Loader;
			//trace(loaderT.width, loaderT.height)
			var bd:BitmapData = new BitmapData(loaderT.width, loaderT.height);
			bd.draw(loaderT)
			bitmap = new Bitmap(bd);
			//bitmap.smoothing = true;
			//bitmap = Bitmap(e.target.content);
		
				bitmap.height = loaderT.height/loaderT.width*thisW;
				bitmap.width = thisW;
				
			bitmap.x = -bitmap.width/2;
			bitmap.y = -bitmap.height/2;
			bitmap.smoothing = true;
			addChild(bitmap);
			
			mcBack.height = bitmap.height + 20;
			
			//mcMask.visible = false;
			//bitmap.mask = mcMask;
			TweenMax.to(this,2,{x:1024/2,y:768/2,delay:1,onComplete:onFinishTween, onCompleteParams:[this],ease:Elastic.easeInOut});

		}
		private function onFinishTween2(head_mc:MovieClip):void {
			this.visible = false;
		}
		private function onFinishTween(head_mc:MovieClip):void {
			var numScale:Number = PicManager.picmanager.targetW/thisW;
			TweenMax.to(head_mc,1,{x:PicManager.picmanager.targetX,y:PicManager.picmanager.targetY,delay:4,alpha:0,scaleX:numScale,scaleY:numScale,ease:Cubic.easeInOut,onComplete:onFinishTween2, onCompleteParams:[this]});
			Main.main.showBigPic();
		}
	}
	
}
